package com.corpdata.system.task;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.corpdata.app.contract.service.ContractInfoService;
import com.corpdata.app.contract.service.ContractReceivableService;
import com.corpdata.app.customer.service.CustomerIntegralService;
import com.corpdata.app.finance.service.FinancialSettingService;

@Component
public class FileTask {
	@Autowired
	FinancialSettingService setServ;
	
	@Autowired
	ContractReceivableService reServ;
	
	@Autowired
	ContractInfoService ciServ;
	
	@Autowired
	CustomerIntegralService integralServ;
	
	 
	/**
	 * 生成账单
	 */
	@Scheduled(cron = "0 0 0 ? * *")
	public void addDill() {
		//获取需要生成账单的应收列表，生成账单
		reServ.generatingBill();
		//发送账单通知
		reServ.sendBillMessage();
		
	}
	
	/**
	 * 发送消息通知
	 */
	@Scheduled(cron = "0 30 0 ? * *")
	public void sendMessage() {
		//合同即将到期通知
		ciServ.sendDaoqiMessage();
		//发送催款通知
		reServ.sendPromptMessage();
	}
	
	/**
	 * 处理合同
	 */
	@Scheduled(cron = "0 0 1 ? * *")
	public void endContract(){
		//合同终止
		ciServ.terminationContract();
		//对今天开始的合同关联工位处理
		ciServ.startContract();
		//删除合同相关临时数据
		ciServ.delTemporaryData();
	}
	/**
	 * 月初积分重新分配
	 */
	@Scheduled(cron = "0 30 1 1 * ?")
	public void pointsReAllot(){
		integralServ.pointsReAllot();
	}
	
	
	
}